package service

import (
	"elegantGo/chapter17/oo"
)

type ArticleDiscountPriceCalculator struct {
	sessionUser oo.User
}

func NewArticleDiscountPriceCalculator(sessionUser oo.User) *ArticleDiscountPriceCalculator {
	srv := new(ArticleDiscountPriceCalculator)
	srv.sessionUser = sessionUser
	return srv
}
func (srv *ArticleDiscountPriceCalculator) Calculate(price int) int {
	// 积分抵扣
	// 节假日活动 618 双11
	// 用户等级

	if vipResourceDiscounter, ok := srv.sessionUser.(oo.UserVipResourceDiscounter); ok {
		price = int(float64(price) * vipResourceDiscounter.Discount())
	}

	return price
}
